package com.zzh.partnersys.common.exception;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author �?�?�?
 * @version 1.0
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    //当他是属于Exception异常，就会自动调用这个方�?
    @ExceptionHandler(Exception.class)
    @ResponseBody//以JSON形式返回数据
    public ResultUtils error(Exception e){
        e.printStackTrace();
        //返回201状态码 + 失败的message
        return ResultUtils.fail(null);
    }


    //自定义异常处�?
    @ExceptionHandler(BusinessException.class)
    @ResponseBody//以JSON形式返回数据
    public ResultUtils error(BusinessException e){
        e.printStackTrace();
        //返回201状态码 + 失败的message
        return ResultUtils.fail(e);
    }
}
